package com.x.erp.manage;

import java.util.Date;

import org.springframework.stereotype.Service;

import com.x.erp.model.Car;
import com.x.erp.model.CarLog;
import com.x.erp.model.CarOrder;
import com.x.erp.util.ConstantState;
import com.x.framework.manage.BaseManage;

/**
 * 预订信息Mapper
 */
@Service
public class CarOrderManage extends BaseManage {

	/**
	 * 新增预订信息
	 * @param carOrder
	 * @param carLog
	 * @return
	 * @throws Exception
	 */
	public CarOrder insertCarOrder(CarOrder carOrder, CarLog carLog) throws Exception {
		Date cDate = new Date();
		carOrder.setOrderCreateTime(cDate);
		carOrder.setOrderUpdateTime(cDate);
		//新增预订信息
		carOrder = this.insert(carOrder);
		Car car = new Car();
		car.setCarId(carOrder.getCarId());
		car.setCarOrderState(ConstantState.CAR_ORDER_STATE_ORDERED);
		this.update(car);//修改车辆预订状态
		//记录日志
		this.insert(carLog);
		return carOrder;
	}

}
